analyses: Find location distribution of squirrels in Central Park in 2018. Analyze the frequency for squirrel sightings by different fur colors. Investigate the relationship of behavior observation and age & fur of squirrels. ANOVA Test/ T-test- whether behavior are associated with age & fur of squirrels Construct data model to predict the behavior/habitat of a specific squirrel
visualizations: Interactive map: Relative habitat of the squirrels in Central Park that match the filter Scatter Plot (Smooth): Whether specific behaviors of squirrels generate (increase) trends according to age Plot: Does the combination of squirrel’s fur color produce a certain regularity of habitat or cluster effect?
analyses: Find location distribution of squirrels in Central Park in 2018. Analyze the frequency for squirrel sightings by different fur colors. Investigate the relationship of behavior observation and age & fur of squirrels. ANOVA Test/ T-test- whether behavior are associated with age & fur of squirrels Construct data model to predict the behavior/habitat of a specific squirrel
visualizations: Interactive map: Relative habitat of the squirrels in Central Park that match the filter Scatter Plot (Smooth): Whether specific behaviors of squirrels generate (increase) trends according to age Plot: Does the combination of squirrel’s fur color produce a certain regularity of habitat or cluster effect?
skimr::skim(census)
| Name | census |
| Number of rows | 3023 |
| Number of columns | 16 |
| _______________________ | |
| Column type frequency: | |
| character | 13 |
| numeric | 3 |
| ________________________ | |
| Group variables | None |
Variable type: character
| skim_variable | n_missing | complete_rate | min | max | empty | n_unique | whitespace |
|---|---|---|---|---|---|---|---|
| unique_squirrel_id | 0 | 1.00 | 13 | 14 | 0 | 3018 | 0 |
| hectare | 0 | 1.00 | 3 | 3 | 0 | 339 | 0 |
| shift | 0 | 1.00 | 2 | 2 | 0 | 2 | 0 |
| date | 0 | 1.00 | 8 | 8 | 0 | 11 | 0 |
| age | 121 | 0.96 | 1 | 8 | 0 | 3 | 0 |
| primary_fur_color | 55 | 0.98 | 4 | 8 | 0 | 3 | 0 |
| highlight_fur_color | 1086 | 0.64 | 4 | 22 | 0 | 10 | 0 |
| combination_of_primary_and_highlight_color | 0 | 1.00 | 1 | 27 | 0 | 22 | 0 |
| location | 64 | 0.98 | 12 | 12 | 0 | 2 | 0 |
| lat_long | 0 | 1.00 | 38 | 45 | 0 | 3023 | 0 |
| activity | 200 | 0.93 | 6 | 8 | 0 | 5 | 0 |
| reaction | 780 | 0.74 | 9 | 11 | 0 | 3 | 0 |
| sounds | 2884 | 0.05 | 4 | 5 | 0 | 3 | 0 |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 | hist |
|---|---|---|---|---|---|---|---|---|---|---|
| hectare_squirrel_number | 0 | 1 | 4.12 | 3.10 | 1.00 | 2.00 | 3.00 | 6.00 | 23.00 | ▇▂▁▁▁ |
| long | 0 | 1 | -73.97 | 0.01 | -73.98 | -73.97 | -73.97 | -73.96 | -73.95 | ▅▇▅▆▂ |
| lat | 0 | 1 | 40.78 | 0.01 | 40.76 | 40.77 | 40.78 | 40.79 | 40.80 | ▇▇▃▅▆ |
glimpse(census)
## Rows: 3,023
## Columns: 16
## $ unique_squirrel_id <chr> "37F-PM-1014-03", "21B-AM-1…
## $ hectare <chr> "37F", "21B", "11B", "32E",…
## $ shift <chr> "PM", "AM", "PM", "PM", "AM…
## $ date <chr> "10142018", "10192018", "10…
## $ hectare_squirrel_number <dbl> 3, 4, 8, 14, 5, 3, 2, 2, 1,…
## $ age <chr> NA, NA, NA, "Adult", "Adult…
## $ primary_fur_color <chr> NA, NA, "Gray", "Gray", "Gr…
## $ highlight_fur_color <chr> NA, NA, NA, NA, "Cinnamon",…
## $ combination_of_primary_and_highlight_color <chr> "+", "+", "Gray+", "Gray+",…
## $ location <chr> NA, NA, "Above Ground", NA,…
## $ lat_long <chr> "POINT (-73.9561344937861 4…
## $ long <dbl> -73.95613, -73.96886, -73.9…
## $ lat <dbl> 40.79408, 40.78378, 40.7755…
## $ activity <chr> NA, NA, "chasing", "eating"…
## $ reaction <chr> NA, NA, NA, "runs_from", NA…
## $ sounds <chr> NA, NA, NA, NA, NA, NA, NA,…
view(census)
nyc_squirrels1=
census%>%
ggplot(aes(long, lat)) +
geom_point() +
theme_map()
nyc_squirrels1
nyc_squirrelmap <- leaflet(data=census1) %>%
addTiles() %>%
addMarkers(lng=~long, lat=~lat, popup= ~hectare,clusterOptions = markerClusterOptions())
nyc_squirrelmap
#这个要在shiny的格式里看,我以防万一还是用了markdown
# primary fur color map
pal_coats <- colorFactor(c("#000000", "#D2691E", "#D3D3D3", "white"), domain = c("Black", "Cinnamon", "Grey", "NA"))
#Locations based on fur color
census %>%
filter(!is.na(primary_fur_color)) %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers(lng = ~long,
lat = ~lat, radius = 3, color = ~pal_coats(primary_fur_color), stroke = FALSE, fillOpacity = 0.5) %>%
addLegend(position ="topright",pal = pal_coats, values = ~primary_fur_color)
omitted<-na.omit(census)
omitted%>%
filter(omitted$age!="?")
## # A tibble: 53 × 16
## unique_sq…¹ hectare shift date hecta…² age prima…³ highl…⁴ combi…⁵ locat…⁶
## <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 16G-AM-101… 16G AM 1010… 3 Adult Gray White Gray+W… Ground…
## 2 4D-PM-1008… 04D PM 1008… 11 Adult Cinnam… Gray, … Cinnam… Above …
## 3 37H-AM-101… 37H AM 1018… 3 Adult Gray White Gray+W… Above …
## 4 22C-AM-101… 22C AM 1013… 2 Adult Cinnam… Gray Cinnam… Above …
## 5 31E-PM-100… 31E PM 1006… 2 Adult Gray Cinnam… Gray+C… Ground…
## 6 37H-PM-100… 37H PM 1006… 2 Adult Gray Cinnam… Gray+C… Ground…
## 7 42G-PM-101… 42G PM 1014… 1 Adult Gray White Gray+W… Above …
## 8 8A-PM-1014… 08A PM 1014… 1 Adult Gray White Gray+W… Ground…
## 9 36F-AM-101… 36F AM 1017… 4 Juve… Gray White Gray+W… Ground…
## 10 9B-AM-1010… 09B AM 1010… 1 Adult Gray Cinnam… Gray+C… Ground…
## # … with 43 more rows, 6 more variables: lat_long <chr>, long <dbl>, lat <dbl>,
## # activity <chr>, reaction <chr>, sounds <chr>, and abbreviated variable
## # names ¹unique_squirrel_id, ²hectare_squirrel_number, ³primary_fur_color,
## # ⁴highlight_fur_color, ⁵combination_of_primary_and_highlight_color,
## # ⁶location
plot(factor(location) ~ factor(age), data = omitted)
plot(factor(location) ~ factor(shift), data = omitted)
plot(factor(location) ~ factor(activity), data = omitted)
plot(factor(location) ~ factor(reaction), data = omitted)
plot(factor(long) ~ factor(activity), data = omitted)
library(revgeo)
revgeo(longitude=-73.968285, latitude=40.785091, provider = 'photon', output='frame')
## [1] "Getting geocode data from Photon: http://photon.komoot.de/reverse?lon=-73.968285&lat=40.785091"
## housenumber street city state
## 1 House Number Not Found Street Not Found City Not Found State Not Found
## zip country
## 1 Postcode Not Found Country Not Found
library(rgdal)
d <- data.frame(lon=census$long, lat=census$lat)
coordinates(d) <- c("lon", "lat")
# Plot the results.
par(mfrow=c(1,3))
plot.default(census$long,census$lat, main="Raw data", cex.axis=.95)
plot(d, axes=TRUE, main="Original lat-lon", cex.axis=.95)
#sf <- st_as_sf(d, coords = c('census$long', 'census$lat'))
#ggplot(sf) +
#geom_sf( )+
#geom_point(aes(census$long, census$lat),color="steelblue") +
#theme_map()